@extends('admin/layout/master')
@section('title', '专栏列表')
@section('title2', '专栏列表')

@section('static')
    <script src="/plus/My97DatePicker/WdatePicker.js"></script>
@endsection

@section('action')
    <a class="layui-btn layui-btn-small layui-btn-normal usersAdd_btn" href="{{ url('/admin/case/create') }}"><i class="layui-icon"></i>专栏添加</a>
    <!-- <a class="layui-btn layui-btn-small layui-btn-danger batchDel"><i class="layui-icon"></i>导出数据</a> -->
@endsection

@section('content')
    <div class="layui-field-box layui-form">
        <form name="mainform" method="post" action="{{ url('/admin/case/dels') }}">
            <table class="layui-table" lay-size="sm">
                <thead>
                <tr>
                    <th style="width: 30px;"><input type="checkbox" lay-filter="allselector" lay-skin="primary" id="qx">
                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div></th>
                    <th>ID</th>
                    <th>专栏名称</th>
                    <th>排序</th>
                    <th style="width: 85px;">操作</th>
                </tr>
                </thead>
                <tbody id="content">
                @foreach ($data as $v)
                    <tr>
                        <td>
                            <input type="checkbox" name="ids[]" value="{{ $v->id }}" lay-skin="primary">
                            <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div>
                        </td>
                        <td>{{ $v->id }}</td>
                        <td>{{ $v->name }}</td>
                        <td>{{ $v->weight }}</td>
                        <td>
                            <div class="layui-btn-group">
                                <a href="{{ url('/admin/case/edit', array('id' => $v->id)) }}" class="layui-btn layui-btn-primary layui-btn-sm"> <i class="layui-icon">&#xe642;</i> </a>
                                <a href="{{ url('/admin/case/destroy', array('id' => $v->id)) }}" onclick="return confirm('确定要删除吗？')" class="layui-btn layui-btn-primary layui-btn-sm"> <i class="layui-icon">&#xe640;</i> </a>
                            </div>
                        </td>
                    </tr>
                @endforeach
                <tr>
                    <td colspan="9" align="center" style="padding:20px 0px;">
                        <div style="display: inline-block;padding-left: 0;">
                            共<span class="pagelink_cur_page"> {{ count($data) }} </span>个专栏
                        </div>
                    </td>
                </tr>
                <tr>
                    {{ csrf_field() }}
                    <td colspan="9" align="center"><a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-mini" onclick="dels()">批量删除</a></td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
@endsection

@section('layuijs')
    <script>
        //一般直接写在一个js文件中
        layui.use(['layer', 'form'], function(){
            var layer = layui.layer
                    ,form = layui.form;
            form.on('checkbox(allselector)', function(data){
                var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
                child.each(function(index, item){
                    item.checked = data.elem.checked;
                });
                form.render('checkbox');
            });
        });
    </script>
    <script>
        //删除
        function dels(){
            layer.confirm('是否批量删除?', {icon: 3, title:'提示'}, function(index){
                document.mainform.submit();
                layer.close(index);
            })
        };
    </script>
@endsection